#include <iostream>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
    int wfd = open(".fifo", O_WRONLY);
    if(wfd < 0)
    {
        std::cerr << "errno: " << errno << ", errstring: " << strerror(errno) <<std::endl;
        return 1;
    }
    std::cout << "client - open sucess...w" << std::endl;

    std::string message;
    while(1)
    {
        std::cout << "Please Enter# ";
        std::getline(std::cin,message);

        ssize_t n = write(wfd, message.c_str(), message.size());
        if(n < 0)
        {
            std::cerr << "errno: " << errno << ", errstring: " << strerror(errno) <<std::endl;
            break;
        }
    }
    close(wfd);
    std::cout << "close wfd sucess..." << std::endl;
    return 0;
}